@using Passwordless.AdminConsole.TagHelpers
@inherits BaseRazorComponent

<span @attributes="AdditionalAttributes" class="@Class">@Message</span>

@code {
    public const string BaseClass = "rounded-md px-2 py-1 text-xs font-semibold";
    
    [Parameter(CaptureUnmatchedValues = true)]
    public Dictionary<string, object>? AdditionalAttributes { get; set; }
    
    [Parameter]
    public ContextualStyles? Variant { get; set; }
    
    [Parameter]
    public string? Message { get; set; }

    protected override Task OnInitializedAsync()
    {
        Class = string.Join(' ', BaseClass, ClassVariant, Class);
        return base.OnInitializedAsync();
    }
    
    private string ClassVariant =>
        Variant switch
        {
            ContextualStyles.Danger => "bg-red-600 text-white",
            ContextualStyles.Success => "bg-green-600 text-white",
            ContextualStyles.Warning => "bg-yellow-600 text-white",
            _ => "bg-blue-600 text-white"
        };
}